﻿using System.Reflection;
using net.entity.framework;
using net.entity.framework.cache;
using net.entity.framework.common;
using net.entity.framework.query;
using net.entity.sandBag.entities;
using net.entity.sandBag.plumbing;

namespace net.entity.sandBag.entities {
    public partial class RoleRef {
        public static readonly RoleRef Unspecified = new RoleRef(-1, TypeIdCache.GetTypeIdByEntityType(typeof (Role)), 0);

        public static EqlRoleRef QueryRoot {
            get { return new EqlRoleRef(new AliasInfo("Mayank", "Role", typeof (Role))); }
        }

        #region Constructors

        public RoleRef(int id, int typeId, int revision) : base(id, typeId, revision) {}

        public RoleRef(int id, int typeId, int revision, QueryContext queryContext)
            : base(id, typeId, revision, queryContext) {}

        #endregion
    }

    public partial class Role {
        public RoleRef AutoRef {
            get { return EntityInvoker.InvokeEntityRef<RoleRef>(this); }
        }
    }
}

namespace net.entity.sandBag.plumbing {
    public class EqlRoleRef : EqlEntityRef {
        public EqlRole T {
            get { return new EqlRole(aliasInfo); }
        }

        public EqlRoleRef(AliasInfo aliasInfo) : base(aliasInfo) {}
        public EqlRoleRef(AliasInfo aliasInfo, PropertyInfo propertyInfo) : base(aliasInfo, propertyInfo) {}
    }

    public class EqlRole : EqlEntity {
        public EqlRole(AliasInfo aliasInfo) : base(aliasInfo) {}

        public Terminal RoleType {
            get {
                return Terminal.Create(aliasInfo, "roleType", typeof (string),
                                       Utils.GetPropertyInfoFromExample(() => ((Role) null).RoleType));
            }
        }
    }
}